<script setup lang="ts">
import { getChannelDataAPI } from '@/apis/channel'
import type { Channel } from '@/types/channel'
import { onMounted, ref } from 'vue'

const channelOptions = ref<Channel[]>([])
onMounted(async () => {
  const res = await getChannelDataAPI()
  // console.log(res.data.channels)
  channelOptions.value = res.data.channels
})

const emit = defineEmits(['update:change'])
const changeFn = () => {
  emit('update:change', channelOptions.value)
}
</script>

<template>
  <el-select clearable placeholder="请选择" style="width: 300px" @change="changeFn">
    <el-option v-for="item in channelOptions" :key="item.id" :label="item.name" :value="item.id" />
  </el-select>
</template>
